using System;
using System.Collections.Generic;
using System.Text;
using GameViewer.Core.Archives;

namespace Plugin_WoW.Archives
{
    public class MpqArchive : Archive
    {
        private MpqReader.MpqArchive mMpq;

        public MpqArchive(string name, string archType)
            : base(name, archType)
        {
        }

        public override void Load()
        {
            mFiles = new List<FileInfo>();
            mMpq = new MpqReader.MpqArchive(mName);
            foreach (MpqReader.MpqArchive.FileInfo file in mMpq.Files)
            {
                FileInfo info = new FileInfo();
                info.Archive = this;
                info.FileName = file.Name;
                info.BaseName = info.FileName;
                info.CompressedSize = file.CompressedSize;
                info.UnCompressedSize = file.UncompressedSize;
                info.Path = "";
                mFiles.Add(info);
            }
        }

        public override System.IO.Stream Open(string fileName)
        {
            return mMpq.OpenFile(fileName);
        }
    }
}
